<?php

class Core_Model_Share extends YouNet_Db_Table_Row
{
    public function saveShareConfig($options)
    {
        if(isset($options['id_contest'])){
            $this->id_contest = $options['id_contest'];
        }
        if(isset($options['title'])){
            $this->title = $options['title'];
        }
        if(isset($options['description'])){
            $this->description = strip_tags($options['description']);
        }
        if(isset($options['image'])){
            $this->image = $options['image'];
        }
        if(isset($options['using_image'])){
            $this->using_image = $options['using_image'];
        }
        $this->save();
    }
	public function getShareTitle()
    {
        return $this->title;
    }
    
    public function getShareDescription()
    {
        return $this->description;
    }
    
    public function getImage()
    {
        $url = "";
        if(!empty($this->image)){
            $url = STATIC_URL . '/media/image/share/' . $this->image;
        }
        return $url;
    }
    public function getShareImage(){
        $url = $this->getImage();
        if($this->using_image == Core_Model_DbTable_Shares::USING_BANNER_IMAGE || empty($url)){
            $contestRow = Core_Model_DbTable_Contests::getContestRow($this->id_contest);
            $url = $contestRow->getBannerImageUrl();
        }
        return $url;
    }
}
